from toutiao_backend_3 import celery_app
# 导入SmsSDK
from ronglian_sms_sdk import SmsSDK
# SmsSDK里的配置信息 配置信息在自己的容联云的配置信息
# [容联云](https://www.yuntongxun.com/)
accId = "8aaf0708842397dd018479fe2bc61f95"
authToken = "c4e60b566665401794c27f6504fe98f1"
appId = "8aaf0708842397dd018479fe2ca01f9c"

@celery_app.task
def sms_code(code, mobile, expire=5):
    """
    :param code: 验证码
    :param mobile: 手机号
    :param expire: 默认时间
    :return:
    """
    # 实例化SmsSDK
    sdk = SmsSDK(accId, authToken, appId)
    tid = '1'
    mobile = "%s" % mobile
    datas = ("%s" % code, "%s" % expire)
    # 发送请求
    resp = sdk.sendMessage(tid=tid, mobile=mobile, datas=datas)
    # 返回resp
    return resp
